package timecost;

public class TestTimeCost {
    public static void loop()
    {
        int cnt = 0;
        for(int i=0; i < 1e9; i++)
        {
            cnt++;
        }
    }
    public static void timecost_test0(){
        long start = System.currentTimeMillis();
        loop(); // 执行代码块
        long end = System.currentTimeMillis();
        System.out.println("func time costs "+ (end - start) + " ms");
    }
    
    public static void timecost_test1()
    {
        TimerUtil tu = new TimerUtil();
        tu.getTime(new Callback() {
            @Override
            public void execute() {
                loop();
            }
        });
    }
    @Timer
    public static void loop2()
    {
        loop();
    }
    public static void timecost_test2()
    {
        TimerUtil tu = new TimerUtil();
        tu.getTime2();
    }
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        System.out.println("***My name is XXX! This is My Code.***");
        timecost_test0();
        timecost_test1();
        timecost_test2();
    }

}
